<template>
  <div v-if="msg.src">
    <div class="bcimg">
      <img width="375" height="210" :src="this.msg.src" alt="" />
      <div class="lt">
        <img @click="goback" class="inlt" width="8" src="../assets/image/lt.png" alt="" />
      </div>
    </div>
    <div class="lesson">
      <div class="title">
        <img @click="showPopup" height="7" class="bottn" src="../assets/image/bottn.png" alt="" />
        <van-popup round top v-model:show="show">{{ this.msg.introduce }}</van-popup>
        <div class="peo">
          <img width="58" :src="this.msg.peopleSrc" alt="" />
        </div>
        <div class="stats">下一课</div>
        <strong>{{ this.msg.mrName }}</strong>
        <i>{{ this.msg.type }}</i>
        <b>{{ this.msg.title }}</b>
        <div class="bordr"></div>
        <em>上课时间:</em>
        <em><van-count-down :time="gettime(this.msg.time)" format="DD天HH:mm:ss" /></em>
        <em class="bafter">后</em>
        <div class="go">go</div>
      </div>
      <div class="work">
        <h2>课前预习</h2>
        <div class="pro">
          <div class="tesks" v-for="item in pro" :key="item.title">
            <div class="pic">
              <img height="42" :src="require('../assets/image/' + item.src + '.png')" alt="" />
              <!-- require('../images/'+imgUrl+'.jpg') -->
            </div>
            <p>{{ item.title }}</p>
            <div class="gt">
              <img width="10" src="../assets/image/ggt.png" alt="" />
            </div>
          </div>
        </div>
        <h2>课后作业</h2>
        <div class="after">
          <div class="tesks" v-for="item in after" :key="item.title">
            <div class="pic">
              <img height="42" :src="require('../assets/image/' + item.src + '.png')" alt="" />
              <!-- require('../images/'+imgUrl+'.jpg') -->
            </div>
            <p>{{ item.title }}</p>
            <div class="gt">
              <img width="10" src="../assets/image/ggt.png" alt="" />
            </div>
          </div>
        </div>
      </div>
      <div class="report">
        <img class="points" width="55" src="../assets/image/points.png" alt="" />
        <p>课后报告</p>

        <div class="show">分享</div>
        <div class="pit">
          <i>分享课后报告</i>
          <div class="pitt"></div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getClassListApi } from "../utils/api";
export default {
  props: ["id"],
  data() {
    return {
      msg: "",
      pro: [],
      after: [],
      show: false,
    };
  },
  created() {
    this.getdata();
  },

  methods: {
    showPopup() {
      this.show = true;
    },
    gettime(timer) {
      let newtime = new Date().getTime();
      return timer - newtime;
    },
    goback() {
      this.$router.go(-1);
    },
    // 数据

    async getdata() {
      let res = await getClassListApi();

      // console.log(res, this.id);
      // console.log(res.classList[1]);
      for (let i = 0; i < res.classList.length; i++) {
        if (res.classList[i].id == this.id) {
          this.msg = res.classList[i];
        }
      }

      res.classList[1].beforeClass.forEach(element => {
        this.pro.push({
          src: element.src.split("/")[3].split(".")[0],
          title: element.title,
        });
      });
      res.classList[1].afterClass.forEach(element => {
        this.after.push({
          src: element.src.split("/")[3].split(".")[0],
          title: element.title,
        });
      });
    },
  },
};
</script>

<style lang="less" scoped>
.bcimg {
  width: 375px;
  height: 203px;
  // background-color: red;
  position: relative;
  .lt {
    position: absolute;
    left: 20.5px;
    top: 60px;
    width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    // box-shadow: 2px -1px 2px black;
    background-color: rgba(0, 0, 0, 0.5);
    // .inlt {
    //   // position: absolute;
    //   // top: 0.5px;
    //   // left: 3px;
    // }
  }
}
.lesson {
  margin-left: 16px;
  width: 344px;
  // background-color: wheat;
  margin-top: -15px;
  // height: 1000px;
  position: relative;

  .title {
    box-shadow: 2px 0 2px gray;
    /deep/.van-popup {
      padding: 10px;
      text-indent: 24px;
      line-height: 16px;
      font-size: 12px;
      text-align: justify;
    }
    .bottn {
      position: absolute;
      top: 84px;
      left: 320px;
    }
    .van-count-down {
      margin-left: 65px;
      margin-top: -2px;
    }
    .peo {
      overflow: hidden;
      position: absolute;
      left: 253.5px;
      top: -30px;
      // background-color: yellow;
      width: 55px;
      height: 55px;
      border-radius: 28px;
    }
    border-radius: 0.53333rem;
    height: 220px;
    background-color: white;
    position: relative;
    .stats {
      color: grey;
      position: absolute;
      width: 55px;
      height: 16px;
      text-align: center;
      line-height: 16px;
      background-color: rgb(238, 238, 238);
      font-size: 12px;
      left: 15.5px;
      top: 19.5px;
    }
    i {
      position: absolute;
      font-weight: 600;
      height: 14px;
      line-height: 15px;
      font-size: 14px;
      left: 15.5px;
      top: 49.5px;
    }
    b {
      color: grey;
      position: absolute;
      height: 14px;
      line-height: 15px;
      font-size: 14px;
      left: 15.5px;
      top: 78px;
    }
    .bordr {
      border: dashed 1px gray;
      position: absolute;
      left: 15.5px;
      top: 106.5px;
      width: 313px;
      height: 1px;
    }
    .bafter {
      margin-left: 152px;
    }
    strong {
      color: grey;
      font-size: 12px;
      position: absolute;
      top: 31px;
      left: 264.5px;
    }
    em {
      position: absolute;
      left: 15.5px;
      top: 122px;
      height: 14px;
      line-height: 15px;
      font-size: 14px;
    }
    .go {
      width: 300px;
      height: 45px;
      border-radius: 23px;
      background-color: rgb(0, 160, 255);
      line-height: 45px;
      color: white;
      text-align: center;
      position: absolute;
      left: 23px;
      top: 155px;
    }
  }
  .work {
    box-shadow: 2px 0 2px gray;
    margin-top: 15px;
    padding-bottom: 30px;
    border-radius: 0.53333rem;
    background-color: white;
    padding-top: 24.5px;
    h2 {
      margin: 0 0 25px 14.5px;
      font-size: 14px;
    }
    .pro {
      margin-bottom: 20px;
      margin-left: 34.5px;
      .tesks {
        width: 275px;
        height: 70px;
        background-color: rgb(245, 245, 245);
        position: relative;
        margin-bottom: 10px;
        border-radius: 5px;
        .pic {
          width: 44.5px;
          height: 42px;
          position: absolute;
          left: 10.5px;
          top: 15.5px;
          // background-color: gold;
        }
        p {
          height: 13.5px;
          font-size: 13.5px;
          position: absolute;
          left: 66px;
          top: 28.5px;
        }
        .gt {
          width: 10px;
          height: 14px;
          position: absolute;
          left: 250px;
          top: 21.5px;
        }
      }
    }
    .after {
      margin-bottom: 20px;
      margin-left: 34.5px;
      .tesks {
        width: 275px;
        height: 70px;
        background-color: rgb(245, 245, 245);
        position: relative;
        margin-bottom: 10px;
        border-radius: 5px;
        .pic {
          width: 44.5px;
          height: 42px;
          position: absolute;
          left: 10.5px;
          top: 15.5px;
          // background-color: gold;
        }
        p {
          height: 13.5px;
          font-size: 13.5px;
          position: absolute;
          left: 66px;
          top: 28.5px;
        }
        .gt {
          width: 10px;
          height: 14px;
          position: absolute;
          left: 250px;
          top: 21.5px;
        }
      }
    }
  }
  .report {
    margin-bottom: 20px;
    overflow: hidden;
    margin-top: 15px;
    padding-bottom: 30px;
    border-radius: 0.53333rem;
    background-color: white;
    // padding-top: 24.5px;
    box-shadow: 2px 0 2px gray;
    font-size: 15px;
    position: relative;
    padding-left: 15px;
    .points {
      position: absolute;
      left: 265px;
    }
    p {
      padding-top: 30px;
      margin-bottom: 17.5px;
    }
    .show {
      position: absolute;
      left: 255.5px;
      top: 55.5px;
      width: 73px;
      height: 30px;
      border-radius: 15px;
      background-color: gainsboro;
      color: #000;
      line-height: 30px;
      text-align: center;
    }
    .pit {
      width: 40px;
      height: 40px;
      border-radius: 20px;
      background-color: rgb(207, 234, 251);
      position: absolute;
      left: -11.5px;
      top: 45.5px;
      i {
        width: 100px;
        position: absolute;
        left: 29px;
        top: 10px;
      }
      .pitt {
        position: absolute;
        width: 20px;
        height: 20px;
        border-radius: 10px;
        background-color: white;
        top: 10px;
        left: 10px;
      }
    }
  }
}
</style>
